﻿/***************************************************************************
 * 文 件 名:   Test_UseTargetCam
 * 
 * 描    述:   Camera多目标切换管理工具，测试脚本
 * 
 * 版    本：  V1.1
 * 创 建 者：  京产肠饭、谭潇杰
 * 创建时间：  2023/5/9
 * 链   接：  https://gitee.com/JingChanChangFan/hk_-unity-tools
****************************************************************************/

using UnityEngine;
using QFramework;
using DG.Tweening;
using HKTools;

public class Test_UseTargetCam : HK_TargetCamController
{
    public Transform testMoveNPC;

    void Start()
    {
        // 注册 开始切换 Target  事件
        this.RegisterEvent<Event_SwitchTargetBegin>(args =>
        {
            Debug.LogFormat("开始 切换至新目标，TargetEnum为：{0}，TargetName为：{1}", args._targetEnum, args._targetName);
        }).UnRegisterWhenGameObjectDestroyed(gameObject);

        // 注册 完成切换 Target  事件
        this.RegisterEvent<Event_SwitchTargetEnd>(args =>
        {
            Debug.LogFormat("完成 切换至新目标，TargetEnum为：{0}，TargetName为：{1}", args._targetEnum, args._targetName);
        }).UnRegisterWhenGameObjectDestroyed(gameObject);
    }

    void Update()
    {
        // --------------Normal----------------
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            this.SendCommand(new CMD_ChangeCamTarget(HK_TargetEnum.Type01, 1));
            this.SendCommand(new CMD_SetCameraState(true));
        }

        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            this.SendCommand(new CMD_ChangeCamTarget(1.2f, HK_TargetEnum.Type02, 4));
            this.SendCommand(new CMD_SetCameraState(false));
        }

        if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            this.SendCommand(new CMD_ChangeCamTarget("RotTarget_03", 2, 2));
            this.SendCommand(new CMD_SetCameraState(true));
        }

        if (Input.GetKeyDown(KeyCode.Alpha4))
        {
            this.SendCommand(new CMD_ChangeCamTarget("RotTarget_04", 2, 8));
            this.SendCommand(new CMD_SetCameraState(true));
        }

        if (Input.GetKeyDown(KeyCode.Alpha5))
        {
            this.SendCommand(new CMD_ChangeCamTarget(HK_TargetEnum.Type05, 3, 6));
            this.SendCommand(new CMD_SetCameraState(true));
        }

        if (Input.GetKeyDown(KeyCode.Alpha6))
        {
            this.SendCommand(new CMD_ChangeCamTarget(HK_TargetEnum.Type06, 4, 10));
            this.SendCommand(new CMD_SetCameraState(true));
        }

        if (Input.GetKeyDown(KeyCode.Alpha7))
        {
            this.SendCommand(new CMD_ChangeCamTarget(HK_TargetEnum.Type07, 4, 10));
            this.SendCommand(new CMD_SetCameraState(true));
        }

        if (Input.GetKeyDown(KeyCode.Alpha8))
        {
            /*---------------------测试-----------------*/
            testMoveNPC.position = new Vector3(-15f, 1, 4.5f);
            testMoveNPC.DOMoveX(13f, 6f).SetEase(Ease.Linear).SetDelay(1f);
            /*------------------------------------------*/

            this.SendCommand(new CMD_ChangeCamTarget(HK_TargetEnum.Type08, 4, 10));
            this.SendCommand(new CMD_SetCameraState(true));
        }

        // --------------Flash----------------
        if (Input.GetKeyDown(KeyCode.Q))
        {
            this.SendCommand(new CMD_ChangeCamTarget(HK_TargetEnum.Type01, 1, true, true));
            this.SendCommand(new CMD_SetCameraState(true));
        }

        if (Input.GetKeyDown(KeyCode.W))
        {
            this.SendCommand(new CMD_ChangeCamTarget(HK_TargetEnum.Type02, 4, true, true));
            this.SendCommand(new CMD_SetCameraState(false));
        }

        if (Input.GetKeyDown(KeyCode.E))
        {
            this.SendCommand(new CMD_ChangeCamTarget("RotTarget_03", 2, 2, true, true));
            this.SendCommand(new CMD_SetCameraState(true));
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            this.SendCommand(new CMD_ChangeCamTarget("RotTarget_04", 2, 8, true));
            this.SendCommand(new CMD_SetCameraState(true));
        }

        if (Input.GetKeyDown(KeyCode.T))
        {
            this.SendCommand(new CMD_ChangeCamTarget(HK_TargetEnum.Type05, 3, 6, true));
            this.SendCommand(new CMD_SetCameraState(true));
        }

        if (Input.GetKeyDown(KeyCode.Y))
        {
            this.SendCommand(new CMD_ChangeCamTarget(HK_TargetEnum.Type06, 4, 10, true));
            this.SendCommand(new CMD_SetCameraState(true));
        }

        if (Input.GetKeyDown(KeyCode.U))
        {
            this.SendCommand(new CMD_ChangeCamTarget(HK_TargetEnum.Type07, 4, 10, true));
            this.SendCommand(new CMD_SetCameraState(true));
        }

        if (Input.GetKeyDown(KeyCode.I))
        {
            /*---------------------测试-----------------*/
            testMoveNPC.position = new Vector3(-15f, 1, 4.5f);
            testMoveNPC.DOMoveX(13f, 6f).SetEase(Ease.Linear).SetDelay(1f);
            /*------------------------------------------*/

            this.SendCommand(new CMD_ChangeCamTarget(HK_TargetEnum.Type08, 4, 10, true));
            this.SendCommand(new CMD_SetCameraState(true));
        }
    }
}
